cc.Class({
    extends: cc.Component,

    properties: {
        handPanel : cc.Node,
        meldPanel : cc.Node,
        discardPanel : cc.Node
        // foo: {
        //    default: null,      // The default value will be used only when the component attaching
        //                           to a node for the first time
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
    },

    // use this for initialization
    onLoad: function () {

    },

    /**
     * 发牌
     */
    dealer : function (MJIds) {
        this.handPanel.getComponent("TopHandPanel").dealer(MJIds);
    },

    /**
     * 摸牌
     */
    mo : function (MJIds) {
        this.handPanel.getComponent("TopHandPanel").mo(MJIds);
    },

    /**
     * 出牌
     */
    discard : function (MJIds) {
        var startPos = this.handPanel.getComponent("TopHandPanel").discard(MJIds);
        this.discardPanel.getComponent("TopDiscardPanel").discard(MJIds, startPos);
    },

    /**
     * 在已出的牌中删除一张牌
     */
    delTile : function (MJId) {
        this.discardPanel.getComponent("TopDiscardPanel").delTile(MJId);
    },

    /**
     * 吃碰杠
     * @param act   {String}        可选 chi|peng|gang
     * @param MJIds {Array|Number}  麻将ID，一组或者一个
     * @param type  {Number}        act为gang时使用，//1:明杠,2:暗杠,3:补杠
     */
    actions : function (act, MJIds, type) {
        this.meldPanel.getComponent("TopMeldPanel").actions(act, MJIds, type);
        this.handPanel.getComponent("TopHandPanel").sort(act, MJIds, type);
    },

    hu : function (handIds, moIds) {
        this.handPanel.getComponent("TopHandPanel").hu(handIds, moIds);
    },

    /**
     * 己方出牌结束，清除出牌指示箭头
     */
    end : function () {
        this.discardPanel.getComponent("TopDiscardPanel").end();
    }
});
